<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width">
    <meta name="keywords" content="网站关键词">
    <meta name="description" content="网站描述">
    <title>提交订单</title>
    <link rel="stylesheet" href="/index/css/style.css">
    <link rel="stylesheet" href="/index/css/responsive.css" />
    <script src="/public/jquery-1.12.3.min.js"></script>
    <script type="text/javascript" src="/index/js/jquery.slide.js"></script>
    <script type="text/javascript" src="/index/js/addons.js" ></script>
    <script type="text/javascript" src="/index/js/user.js" ></script>
    <script type="text/javascript" src="/index/js/login.js" ></script>
    <!--[if lt IE 9]>
    <script src="/index/js/html5.index/js"></script>
    <![endif]-->
</head>
<body style="background: #f8f8f8;">
<!--conter -->
<div class="contert-box wrapper clearfix"style="margin-left: 0px;">
    <div class="right-box fr" style="height: auto;float: left">
        <h6></h6>
        <div class="data">
            <form>
                <ul>
                    <li class="clearfix">
                        <h5 class="fl">地区选择：</h5>
                        <div class="fl select">
                            <select name="shen" id="shen">
                                <option value="">请选择省</option>
                                {volist name='shengList' id='info'}
                                <option value="{$info.id}">{$info.name}</option>
                                {/volist}
                            </select>
                            <select name="shi" id="shi">
                                <option value=""></option>
                            </select>
                            <select name="xian" id="xian">
                                <option value=""></option>
                            </select>
                        </div>
                    </li>
                    <li class="clearfix">
                        <h5 class="fl">详细地址：</h5>
                        <div class="inps fl">
                            <textarea type="text" id="address"></textarea>
                        </div>
                    </li>
                    <li class="clearfix">
                        <h5 class="fl">收货人姓名：</h5>
                        <div class="inps fl">
                            <input type="text" id="name" value="" />
                        </div>
                    </li>
                    <li class="clearfix">
                        <h5 class="fl">手机号码：</h5>
                        <div class="inps fl">
                            <input type="text" id="phoneIpt" value=""/>
                        </div>
                    </li>
                    <li class="clearfix">
                        <h5 class="fl">验证码：</h5>
                        <div class="inps fl">
                            <input type="text" id="yanma" placeholder="请输入验证码" value=""/>
                        </div>
                        <button type="button" onclick="logyanma()" style="border: 1px solid #eee;margin-left: 10px;height: 34px;">发送验证码</button>
                    </li>
                    <input hidden type="text" id="drawing_id" value="{$drawing_id}"/>
                    <li class="clearfix">
                        <h5 class="fl">备注：</h5>
                        <div class="inps fl">
                            <textarea type="text" id="remarks" /></textarea>
                        </div>
                    </li>
                </ul>
            </form>
            <div class="checkbox clearfix">
                <div class="fl"><button onclick="buyImg()">提交</button></div>
            </div>
        </div>
    </div>
</div>
<!--conter end-->
{include file="public/comscript" /}
</body>
</html>
<script>
    $("#shen").change(function(){
        var url = "addressList";
        var opt=$("#shen").val();
        address_post_sub(url,{id:opt},$('#shi'));
        $("#address").val($('#shen').find("option:selected").text());
    });
    $("#shi").change(function(){
        var url = "addressList";
        var opt=$("#shi").val();
        address_post_sub(url,{id:opt},$('#xian'));
        $("#address").val($('#shen').find("option:selected").text()+$('#shi').find("option:selected").text());
    });
    $("#xian").change(function(){
        $("#address").val($('#shen').find("option:selected").text()+$('#shi').find("option:selected").text()+$('#xian').find("option:selected").text());
    });
    function buyImg() {
        var address,tel,name,sheng,shi,xian,remarks,drawing_id,yanma;
        tel = $.trim($("#phoneIpt").val());
        sheng = $.trim($("#shen").val());
        shi = $.trim($("#shi").val());
        xian = $.trim($("#xian").val());
        name = $.trim($("#name").val());
        address = $.trim($("#address").val());
        remarks = $.trim($("#remarks").val());
        drawing_id = $.trim($("#drawing_id").val());
        yanma = $.trim($("#yanma").val());
        if(address == ""){
            layer.alert('请填写地址!',{icon: 2},function(index){
                layer.close(index);
            });
            return false;
        }
        if(name==""){
            layer.alert('请填写名字!',{icon: 2},function(index){
            });
            return false;
        }
        if(tel == ""){
            layer.alert('请填写电话!',{icon: 2},function(index){
                layer.close(index);
            });
            return false;
        }
        if(tel.length!=11||isNaN(tel)||parseInt(tel)<=0){
            layer.alert('您填写的手机号码格式错误!',function(index){
                layer.close(index);
            });
            return false;
        }
        $.ajax({
            type :"POST",
            url : __HOME__+"buyImg",
            data:{
                "tel":tel,
                "sheng":sheng,
                "shi":shi,
                "xian":xian,
                "name":name,
                "address":address,
                "remarks":remarks,
                "drawing_id":drawing_id,
                "yanma":yanma
            },
            async : true,
            dataType:'json',
            success : function(result) {
                if(result=='1'){
                    layer.alert('您的订单提交成功!',{icon: 1},function(index){
                        layer.close(index);
                        return false;
                    });
                }
                var index2 = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index2);
                // window.location.href = __HOME__+"receiverAddress";
            },
            error : function() {
                alert("当前网络可能较差请稍后再试");
            }
        });
    }
</script>
